import axios from 'axios'

const service = axios.create({
  //axios的全局配置
  baseURL: process.env.VUE_APP_BASE_API,
  timeout: 5000
})

//配置axios的请求拦截器
service.interceptors.request.use(config => {
  // 全局设置请求头
  config.headers.token = localStorage.getItem('token')
  return config
})
//响应拦截器
service.interceptors.response.use(response => {
  const res = response.data
  return res
})
export default service
